# Maintainer: Bradley Saulteaux <~@bradso.to>
pkgname=textadept
pkgver=10.3
_pkgver=e7c3dfab62a7
_scintver=8b888bf05fe3
_gtdver=988719013a6a
_luaver=5.3.5
_lpegver=1.0.1
_lfsver=1_7_0_2
_cdkver=5.0-20150928
_tkver=0.20
pkgrel=0
pkgdesc="A fast, minimalist, and remarkably extensible cross-platform text editor"
url="https://foicica.com/textadept/"
arch="all !mips !mips64"
license="MIT"
depends="gtk+2.0"
makedepends="curl ncurses-dev gtk+2.0-dev lua5.3-dev cloc"
install=""
options="!check"
subpackages="${pkgname}-curses"
source="${pkgname}-${pkgver}.zip::https://foicica.com/hg/${pkgname}/archive/${_pkgver}.zip
	http://foicica.com/hg/scintilla/archive/${_scintver}.zip
	http://foicica.com/hg/gtdialog/archive/${_gtdver}.zip
	http://www.lua.org/ftp/lua-${_luaver}.tar.gz
	http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-${_lpegver}.tar.gz
	http://github.com/keplerproject/luafilesystem/archive/v${_lfsver}.tar.gz
	http://invisible-mirror.net/archives/cdk/cdk-${_cdkver}.tgz
	http://www.leonerd.org.uk/code/libtermkey/libtermkey-${_tkver}.tar.gz
	"
builddir="$srcdir/${pkgname}-${_pkgver}/src"

prepare() {
	default_prepare
	mv ../../scintilla-${_scintver} scintilla
	patch -d scintilla -N -p1 < scintilla.patch
	mv ../../gtdialog-${_gtdver} gtdialog
	mv ../../lua-${_luaver} lua
	patch -d lua -N -p1 < lua.patch
	mkdir lua/src/lib
	mv ../../lpeg-${_lpegver}/* lua/src/lib/
	mv ../../luafilesystem-${_lfsver}/src/* lua/src/lib/ 
	mv ../../cdk-${_cdkver} cdk
	mv cdk/include/*.h cdk/
	patch -d cdk -N -p1 < cdk.patch
	mv ../../libtermkey-${_tkver} termkey
	patch -d termkey -N -p1 < termkey.patch
}

build() {
	make CFLAGS="${CFLAGS} -I/usr/include/lua5.3" CXXFLAGS="${CXXFLAGS} -I/usr/include/lua5.3"
	make CFLAGS="${CFLAGS} -I/usr/include/lua5.3" CXXFLAGS="${CXXFLAGS} -I/usr/include/lua5.3" ${pkgname}-curses
}
	
curses() {
	depends="ncurses-libs"
	mkdir -p "$subpkgdir"/usr/bin
	mkdir -p "$subpkgdir"/usr/share/applications/
	mv "$srcdir/${pkgname}-${_pkgver}/${pkgname}-curses" "$subpkgdir"/usr/bin/
	rm "$builddir/${subpkgname}.desktop"
}

package() {
	make WGET=":" DESTDIR="$pkgdir" PREFIX="/usr" install
	chmod -x "$pkgdir"/usr/share/applications/*.desktop
	rm "$pkgdir"/usr/share/applications/${pkgname}-curses.desktop
}
sha512sums="58c5824df2f16a730d420ed2f331b7e9c7aff1330d58b8a68c46ef90f736acdfc7b9d770bbce02aa7eb0afdd5c2b3967650ebf23f652645d676f536cafaea9a2  textadept-10.3.zip
a7bb469b9d2a34a951b7cf8907d890e609a3d1117f5b6952f8da233cef7cfc519a330cfe22abb3ca50a5d64e4028ebef968fa555f573712643a55ac142d47853  8b888bf05fe3.zip
df7e86317fc9c4113c4699993be799efc9cb9c8f50d9415ceed9218a0d331a086c9a04853aba8f0fdc6ca45b1009d8bf19096fac216686afa02f560fea6eafb9  988719013a6a.zip
4f9516acc4659dfd0a9e911bfa00c0788f0ad9348e5724fe8fb17aac59e9c0060a64378f82be86f8534e49c6c013e7488ad17321bafcc787831d3d67406bd0f4  lua-5.3.5.tar.gz
7b43fbee7eff443000986684bc56bba6d2796a31cf860740746c70e155bdea1b62a46b93f97e2747e3ef0f63e965148778ac2985d0f2d83e1e37ec4ebbabf4aa  lpeg-1.0.1.tar.gz
a1d4d077776e57cd878dbcd21656da141ea3686c587b5420a2b039aeaf086b7e7d05d531ee1cc2bbd7d06660d1315b09593e52143f6711f033ce8eecdc550511  v1_7_0_2.tar.gz
5774e28d91edd477854e30eb456b7725987e82ec27f5cf055c1d1e46581e11d2958bafbac408124f274bf7454be68476d18643a265df7c74b8f43eb1895bf19d  cdk-5.0-20150928.tgz
81a4bc5917c60ca692ec3065ac0252ae5dc1adccc2832be1c83c82318c97473d883900ab88a8a0ee08ab3f831ff07f3a4827ee3d8e936a3a42c4708ee58f6301  libtermkey-0.20.tar.gz"
